<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>操作DOM的案例</title>
</head>

<body>
    <span id="textBox">0</span>
    <br>
    <button id="add">累加</button>


    <script>

        /* 
        
           传统的前端开发以操作dom为主，来实现交互效果
        */
        // 想操作谁就先获取谁
        let textBox = document.querySelector('#textBox')
        let add = document.querySelector('#add')

        // 给按钮绑定点击事件
        let num = 0
        add.addEventListener('click', function () {
            num++
            textBox.innerHTML = num
        })

    </script>
</body>

</html>